package servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import dao.TeacherDao;
import entity.Teacher1;

public class TeacherInsertServlet extends HttpServlet{
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
//		Goods g=dao.findGoodById(Integer.parseInt(id));
		
		req.setCharacterEncoding("UTF-8");
		resp.setCharacterEncoding("UTF-8");
		String id=req.getParameter("id");
		String name=req.getParameter("name");
		String idcard=req.getParameter("idcard");
		String department=req.getParameter("department");
		String phone=req.getParameter("phone");
		TeacherDao td=new TeacherDao();
		td.insertTeacher(id, name, idcard, department, phone);
//		List<Teacher1> listInsert=td.insertTeacher(getInitParameter("id"),getInitParameter("name"), getInitParameter("idcard"), getInitParameter("department"), getInitParameter("phone"));
		HttpSession session=req.getSession();
//		session.setAttribute("listQuery",listInsert);
		resp.sendRedirect("teacherinsert.jsp");
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(req, resp);
	}

}
